package com.studerb.tasks;

//package com.studerb.service;
//
//import java.util.concurrent.BlockingQueue;
//
//import com.studerb.model.Server;
//import com.studerb.nntp.NntpConnException;
//import com.studerb.nntp.NntpConnection;
//import com.studerb.util.Producer;
//
//public class ListGroupsProducer extends Producer {
//	private Server server;
//	NntpConnection conn;
//	
//	ListGroupsProducer(BlockingQueue<Object> theQueue) {
//		super(theQueue);
//		this.server = server;
//	}
//
//	@Override
//	protected Object getRequestFromNetwork() {
//		try {
//			Server master = ServerService.getMasterServer();
//			log.info("updating all groups from server: " + master.toString());
//			conn = new NntpConnection(master);
//			conn.connect();
//			int reply = conn.sendCommand(NNTPCommand.LIST);
//			if ((!NNTPReply.isPositiveCompletion(reply))||
//				(reply != NNTPReply.LIST_OF_NEWSGROUP_FOLLOWS))
//				throw new ServiceException("Error listing groups: reply: " + conn.getReply());
//			reader = new BufferedReader(new DotTerminatedMessageReader(conn.getReader()));
//			String temp;
//			lines = new ArrayList<String>();
//			while ((temp = reader.readLine()) != null) {
//				lines.add(temp);
//			}
//			log.info("Downloaded: " + lines.size() + " groups");
//		} 
//		catch(NntpConnException e){
//			//send message about connection exception
//		}
//		finally {
//			conn.disconnect();
//			queue.add("x");
//			
//		}
//	}
//}